<?php
class Reports extends MySQLCN 
{

    function DailyAttendanceReport($punch_date,$dept) 
	{
	
		$strSQL = "SELECT atnd.*,emp.*,dept.* 
					FROM attendance as atnd INNER JOIN users as emp ON atnd.empunq_id=emp.login INNER JOIN dept_master as dept ON emp.department=dept.dept_id";
			$conditions = array();
			if ($punch_date != '') 
			{
             $conditions[] = 'atnd.punch_date = "'.mysql_real_escape_string($punch_date).'"';
            }
			if ($dept != '') 
			{
             $conditions[] = 'emp.department = "'.$dept.'"';
            }
			if(count($conditions))
			{
				$strSQL.= ' WHERE '.implode(' AND ', $conditions);
			}
		 return $this->select($strSQL);
	
	}
	function DailyAbsentReport($punch_date,$dept) 
	{
		
		$strSQL = "SELECT atnd.*,emp.*,dept.* 
					FROM attendance as atnd INNER JOIN users as emp ON atnd.empunq_id=emp.login INNER JOIN dept_master as dept ON emp.department=dept.dept_id";
					
			$conditions = array();
			if ($punch_date != '') 
			{
             $conditions[] = 'atnd.punch_date = "'.mysql_real_escape_string($punch_date).'"';
            }
			if ($_REQUEST['dept'] != '') 
			{
             $conditions[] = 'emp.department = "'.$dept.'"';
            }
			$conditions[] = 'atnd.latemarksts = 0';
			if(count($conditions)) 
			{
				$strSQL.= ' WHERE '.implode(' AND ', $conditions);
			}
		return $this->select($strSQL);
	
	}
	function DailyLateMarkReport($punch_date,$dept) 
	{
	$strSQL = "SELECT atnd.*,emp.*,dept.* 
					FROM attendance as atnd INNER JOIN users as emp ON atnd.empunq_id=emp.login INNER JOIN dept_master as dept ON emp.department=dept.dept_id";
			$conditions = array();
			if ($punch_date != '') {
             $conditions[] = 'atnd.punch_date = "'.mysql_real_escape_string($punch_date).'"';
            }
			if ($_REQUEST['dept'] != '') {
             $conditions[] = 'emp.department = "'.$_REQUEST['dept'].'"';
            }
			$conditions[] = 'atnd.latemarksts = 2';
			if(count($conditions)) {
				$strSQL.= ' WHERE '.implode(' AND ', $conditions);
			}	
		return $this->select($strSQL);
	}
	
	function MonthlyLateMarkReport() 
	{
	
	
	
	
	}
	function MonthlyAttendanceReport($deptid) 
	{
    	$strSQL1 = "SELECT emp.*,dept.* FROM users as emp INNER JOIN dept_master as dept ON emp.department=dept.dept_id";
			$conditions1 = array();	
			if ($deptid != '') {
				$conditions1[] = 'emp.department = "'.$deptid.'"';
			}	
			if(count($conditions1)) {
				$strSQL1.= ' WHERE '.implode(' AND ', $conditions1);
			}

        return $this->select($strSQL1);	
	
	}
	
	function MonthlyAttendanceSupport($wday,$uid) {
		$strSQL2 = "SELECT punch_date,latemarksts FROM attendance";
		$conditions2 = array();
		$conditions2[] = 'punch_date = "'.$wday.'"';
		$conditions2[] = 'empunq_id = "'.$uid.'"';
		if(count($conditions2)) {
			$strSQL2.= ' WHERE '.implode(' AND ', $conditions2);
		}
	
	 return $this->select($strSQL2);	
	
	}
	
	function AnnualAttendanceReport($wday,$uid)
	{
     $strSQL2 = "SELECT punch_date,latemarksts FROM attendance";
		$conditions2 = array();
		$conditions2[] = 'punch_date = "'.$wday.'"';
		$conditions2[] = 'empunq_id = "'.$uid.'"';
		if(count($conditions2)) {
			$strSQL2.= ' WHERE '.implode(' AND ', $conditions2);
		}
	
	 return $this->chknum($strSQL2);

	}
	
}

?>
